const DB = require('../tools/mysql')

module.exports = async ctx => {

	// const { ids } = ctx.request.body

	// const idlist = ids.split(',')

	// let data = [], county = []

	// for (var i = 0; i < idlist.length; i++) {
	// 	county = await DB('placename').select('placename.id', 'placename.pid', 'placename.name as pname', 'organization.level', 'organization.name as oname').leftJoin('organization', 'placename.org', 'organization.id').where('placename.id', idlist[i])
	// 	data = await DB('placename').select('placename.id', 'placename.pid', 'placename.name as pname', 'organization.level', 'organization.name as oname').leftJoin('organization', 'placename.org', 'organization.id').where('placename.pid', idlist[i])
	// 	for (var i = 0; i < data.length; i++) {
	// 		const level = await DB('placename').select('placename.id', 'placename.pid', 'placename.name as pname', 'organization.level', 'organization.name as oname').leftJoin('organization', 'placename.org', 'organization.id').where('placename.pid', data[i].id)
	// 		data = data.concat(level)
	// 	}
	// }

	// data = data.concat(county)

	const data = await DB('placename').select('placename.id', 'placename.pid', 'placename.name as pname', 'organization.level', 'organization.name as oname').leftJoin('organization', 'placename.org', 'organization.id')

  ctx.body = { code: 1, msg: '查询成功', data }

}